#!/usr/bin/env python3
import os
import re

#markup file
def mdtohtml(str):
	#some cosmetics
	str = str.replace("(c)","&copy;")
	str = str.replace("(r)","&reg;")
	str = str.replace("(tm)","&trade;")
	#replace "<" and ">" with entities
	str = str.replace("<","&lt;")
	str = str.replace(">","&gt;")
	str = str.replace("\n&gt;","\n>")

	#convert markdown to html using the "Markdown" python module
	#not working? install python and pip, then the markdown module
	#for Debian, Ubuntu, Linux Mint and Debian-based distros: "sudo apt install python3-pip"
	#then: "pip3 install markdown"
	open("tmp.md","a").write(str)
	os.system("python3 -m markdown tmp.md > tmp.html")
	os.system("rm -f tmp.md")
	str_html = open("tmp.html").read()
	os.system("rm -f tmp.html")

	return str_html
